//
//  StatusCell.swift
//  Weibo
//
//  Created by gdarkness on 16/3/28.
//  Copyright © 2016年 gdarkness. All rights reserved.
//

import UIKit

class StatusCell: UITableViewCell {
    
    //MARK: -属性
    //微博模型
    var status: Status? {
        didSet{
            // 当控制器把模型传给cell的时候调用
            // 将模型传递给StatusOriginalView
            originalView.status = status
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //实现这个构造函数
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        backgroundColor = UIColor(white: 237 / 255.0, alpha: 1)
        //实现这个构造函数
        prepareUI()
    }
    
    
    
    private func prepareUI() {
        //添加子控件
        contentView.addSubview(originalView)
        contentView.addSubview(bottomView)
        
        //添加约束
       originalView.snp_remakeConstraints { (make) -> Void in
        make.top.equalTo(contentView).offset(10)
        make.leading.trailing.equalTo(contentView)
       // make.height.equalTo(44)
    }
        bottomView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(originalView.snp_bottom)
            make.leading.trailing.equalTo(contentView)
            make.height.equalTo(44)
        }
        //当使用autolayout来约束cell里面的空间并且cell的高度想通过autolayout来自动确定，需要给contentView添加约束
        contentView.snp_makeConstraints { (make) -> Void in
            make.leading.top.trailing.equalTo(self)
            make.bottom.equalTo(bottomView)
        }
 
}
    
    
    private lazy var originalView: StatusOriginaView = StatusOriginaView()
    
    private lazy var bottomView: StatusBottomView = StatusBottomView()
}
